LadiPageScriptV2.prototype.sendFormCheckout=function(t,e){var i=this,a=(t=i.findAncestor(t,"ladi-element")).getAttribute("data-payment");a=JSON.parse(a);var n=Array.from(t.querySelectorAll('[data-form-checkout-item="product"] .ladi-form-checkout-payment-check.checked')).map(function(t){var e=i.findAncestor(t,"ladi-form-checkout-box"),a=JSON.parse(e.getAttribute("data-product"));a.quantity=1;var n=e.querySelector(".ladi-form-checkout-payment-quantity input");return isEmptyLadiPage(n)||(a.quantity=parseInt(n.value)||a.quantity),a}),o=isObjectLadiPage(i.runtime.payment_setting)?i.runtime.payment_setting:{},r=e.setFormData(t,!1),c=r.formDataObject,d=((r=e.setFormDataObjectThankyou()).formDataObjectThankyou,r.formDataObjectConvertThankyou),s=isEmptyLadiPage(c.name)?"":c.name,u=isEmptyLadiPage(c.email)?"":c.email,l=isEmptyLadiPage(c.phone)?"":c.phone,p=!1,m=!1,_=!0,g=0,f=function(t,e){return t},h=function(a){var n=o.thankyou_type,r=o.thankyou_value,c=!1;i.runtime.has_popupx&&i.runtime.tmp.popupx_is_inline&&(c=!0);var s=i.runtime.eventData[t.id]["option.form_auto_funnel"],u="";n==i.const.FORM_THANKYOU_TYPE.default&&(isEmptyLadiPage(r)||i.showMessage(r,d)),n==i.const.FORM_THANKYOU_TYPE.popup&&(s&&i.setDataReplaceElement(!1,!1,d,r),window.ladi(r).show(!1,{formThankyouPopupXInline:c})),n!=i.const.FORM_THANKYOU_TYPE.url&&n!=i.const.FORM_THANKYOU_TYPE.url_default||isEmptyLadiPage(a)||(r=window.ladi(a).encode_thankyou_url(),u=f(r),i.runTimeout(function(){window.ladi(u).open_url()},0)),e.resetFormValue(t.querySelector(".ladi-form"))},y=function(t,e){"Success"==t&&h(e.thanks_url),"Canceled"==t&&i.showMessage(i.const.LANG.FORM_CHECKOUT_ORDER_CANCEL)};window.formCheckoutDownloadQRCode=function(){const t=document.getElementById("form-checkout-bank-qr").src;fetch(t).then(t=>t.blob()).then(t=>{const e=new FileReader;e.onloadend=function(){const t=e.result,i=document.createElement("a");i.href=t,i.download="qr_code.png",document.body.appendChild(i),i.click(),document.body.removeChild(i)},e.readAsDataURL(t)}).catch(t=>console.error("Error downloading image:",t))},window.formCheckoutCopyToClipboard=function(t){const e=t.closest(".info-row"),i=e?e.querySelector(".info-value"):null;if(i){const e=i.textContent.trim(),a=document.createElement("input");a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.value=e,a.select(),document.execCommand("copy"),document.body.removeChild(a);const n=t.querySelector(".tooltiptext.right"),o=n.getAttribute("tooltiptext");n.setAttribute("tooltiptext","Copied to clipboard!"),n.style.visibility="visible",n.style.opacity="1",setTimeout(()=>{n.setAttribute("tooltiptext",o),n.style.visibility="hidden",n.style.opacity="0"},2e3)}else console.error("The .info-value element was not found.")},window.formCheckoutClosePopupQRCode=function(){p=!0;var t=document.querySelector(".ladipage-message");t&&t.remove();var e=document.querySelector("body .ladi-wraper");e&&(e.style.display="block"),i.removeTimeout(g),g=null};var v=function(t){p=!1;var e="form-checkout-bank-qr",a=t.bank_info.banks[0].autoConfirmPayment;const n=document.querySelector("body .ladi-wraper"),o=window.innerWidth<=768;if(n&&o?n.style.display="none":n&&(n.style.display=""),isEmptyLadiPage(document.getElementById(e))){LadiPageScript.showMessage(`\n \n
\n \n
Thanh toán chuyển khoản ngân hàng
\n ${a?'\n
\n
Đang chờ thanh toán
\n
\n
\n
\n Loading\n
\n\n \n\n ':'
Đây là nội dung mà người dùng cấu hình ở phần hướng dẫn chuyển khoản trong phần thiết lập phương thức thanh toán. Chỉ hiển thị ra.
'}\n \n
\n\n
\n
\n
Quét mã QR thanh toán
\n \n
\n
Tải xuống mã QR
\n \n
\n
Mở app ngân hàng hoặc ví điện tử của bạn sau đó chọn quét mã QR để thực hiện thanh toán.
\n
\n ${function(){try{return`\n
\n
\n Chuyển khoản thủ công theo thông tin\n
\n \n
\n
\n
\n \n\n
\n
\n
Ngân hàng
\n
${t.bank_info.banks[0].bank.shortName}
\n
\n
\n
Thụ hưởng
\n
${t.bank_info.banks[0].accountName}
\n
\n
\n
Số tài khoản
\n
${t.bank_info.banks[0].accountNumber}
\n
\n Copy\n
\n
\n
\n
\n
Số tiền
\n
${i.formatCurrency(t.bank_info.amount,t.bank_info.currency_symbol,!0)}
\n
\n Copy\n
\n
\n
\n
\n
Nội dung CK
\n
${t.bank_info.banks[0].transferContentPrefix} ${t.bank_info.reference_no}
\n
\n Copy\n
\n
\n
\n ${a?`\n
\n Lưu ý: Vui lòng giữ nguyên nội dung ${t.bank_info.banks[0].transferContentPrefix} ${t.bank_info.reference_no} để xác nhận thanh toán tự động\n
\n `:""}\n \n
\n
\n
\n `}catch(t){return""}}()}\n
\n `)}!m&&a&&(!function(t){const e=document.querySelector(".count-down"),a=document.getElementById("countdown-timer"),n=document.getElementById("countdown-message"),o=document.querySelector(".close-popup"),r=document.querySelector(".sub-title");let c=Date.now()+60*t*1e3;a.style.display="block",n.style.display="none",o.style.display="block",function t(){const d=Math.max(0,c-Date.now()),s=Math.floor(d/6e4),u=Math.floor(d%6e4/1e3);a.textContent=`${String(s).padStart(2,"0")} phút ${String(u).padStart(2,"0")} giây`,d>0?g=i.runTimeout(t,1e3):(n.style.textAlign="center",n.style.display="block",n.style.color="#E01A1A",n.style.maxWidth="632px",o.style.display="block",e.style.display="none",r.style.display="none")}()}(5),m=!0);var r=new XMLHttpRequest;r.open("POST",i.const.API_LADISALE_CHECKOUT_GET_ORDER_STATUS),r.addEventListener("readystatechange",function(){if(4===this.readyState)try{var e=JSON.parse(this.responseText);if(200!=e.code)throw new TypeError("api error");if("Pending"==e.data.payment_status||"OnHold"==e.data.payment_status)throw new TypeError("fetch api");y(e.data.payment_status,t)}catch(e){setTimeout(function(){!p&&v(t)},1e4)}}),r.setRequestHeader("content-type","application/json"),_&&!p&&(_=a,r.send(JSON.stringify({ls_data:t.ls_data})))},E="";o.thankyou_type==i.const.FORM_THANKYOU_TYPE.url&&(E=f(o.thankyou_value)),isEmptyLadiPage(i.runtime.tmp.form_checkout_order_id)&&(i.runtime.tmp.form_checkout_order_id=i.randomString(10)),i.showLoadingBlur();try{var L=JSON.stringify({thank_url:E,source_from:"LP",invoiceInfo:{isEnable:!1},url:window.location.href,gateway:a,product_one_page:!0,lang:"vi",domain:window.location.hostname,path:window.location.pathname.substring("/".length),path_type:"product",cart_token:!1,checkout_token:!1,customer_first_name:s,customer_email:u,customer_phone:l,is_export_invoice:!1,variants:n.map(function(t){return{product_id:t.product_id,product_variant_id:t.product_variant_id,quantity:t.quantity,store_id:i.runtime.store_id_int}}),utm:{url_pathname:window.location.pathname,url_search:window.location.search,url_page:window.location.href},custom_fields_checkout:[]}),P=new XMLHttpRequest;P.addEventListener("readystatechange",function(){4===this.readyState&&(!function(t){try{var e=JSON.parse(t);if(200!=e.code||!isObjectLadiPage(e.data))return i.showMessage(e.message);if(e.data,!isEmptyLadiPage(e.data.redirect_url))return void(window.location.href=e.data.redirect_url);if(isObjectLadiPage(e.data.bank_info)&&!isEmptyLadiPage(e.data.bank_info.qr_url)&&!isEmptyLadiPage(e.data.ls_data)&&!p)return void v(e.data);h(e.data.thanks_url)}catch(t){return i.showMessage(i.const.LANG.REQUEST_SEND_ERROR)}}(this.responseText),i.hideLoadingBlur())}),P.open("POST",i.const.API_LADISALE_CHECKOUT_PAYMENT),P.setRequestHeader("Content-Type","application/json"),P.send(L)}catch(t){i.hideLoadingBlur()}},LadiPageScriptV2.prototype.eventFormCheckoutSelectPaymentType=function(t){var e=this;e instanceof LadiPageScriptV2||(e=LadiPageScript),t.stopPropagation();var i=e.findAncestor(t.target,"ladi-form-checkout-box"),a=e.findAncestor(t.target,["ladi-form","ladi-element"]);e.showMessage("\n \n \n ");var n=function(){document.querySelector(".ladipage-message-close").click()},o=function(t){var e=a.querySelector('.ladi-element[data-form-checkout-item="payment"] .ladi-form-checkout-box[data-payment-code="'+t.code+'"] .ladi-form-checkout-payment-content span:last-child');e.hasAttribute("data-old")||e.setAttribute("data-old",e.textContent),isEmptyLadiPage(t.code)?e.textContent=e.getAttribute("data-old"):e.textContent=t.method_title||e.getAttribute("data-old"),isEmptyLadiPage(t.code)||(Array.from(a.querySelectorAll('[data-form-checkout-item="payment"] .ladi-form-checkout-payment-check.checked')).forEach(function(t){t.classList.remove("checked")}),Array.from(a.querySelectorAll('[data-form-checkout-item="payment"] [data-payment-code="'+t.code+'"] .ladi-form-checkout-payment-check')).forEach(function(t){t.classList.add("checked")})),a.setAttribute("data-payment",JSON.stringify(t)),n()},r=document.querySelector(".ladipage-message-text iframe"),c=function(){var t=isObjectLadiPage(e.runtime.payment_setting)?e.runtime.payment_setting:{},c=a.hasAttribute("data-payment")?JSON.parse(a.getAttribute("data-payment")):{};c.code=i.getAttribute("data-payment-code");var d=e.runtime.tmp.html_payment_str;r.contentWindow.payment_continue=o,r.contentWindow.payment_cancel=n,r.contentWindow.payment_setting=t,r.contentWindow.current_select=c,r.contentWindow.ladi_uid=e.runtime.store_id_int,r.contentWindow.end_point_api=e.const.API_LADISALE_LIST_GATEWAY,r.contentDocument.open(),r.contentDocument.write(d),r.contentDocument.close()};isEmptyLadiPage(e.runtime.tmp.html_payment_str)?fetch(e.const.URL_LADI_PAYMENT()).then(t=>t.text()).then(t=>{e.runtime.tmp.html_payment_str=t,c()}).catch(t=>{}):c()},LadiPageScriptV2.prototype.checkValidateSendFormCheckout=function(t){try{if(0==t.querySelectorAll('[data-form-checkout-item="product"] .ladi-form-checkout-payment-check.checked').length)throw new TypeError("no product")}catch(t){return this.showMessage(this.const.LANG.FORM_VALIDATE_CHECKOUT_PRODUCT),!1}try{var e=JSON.parse(t.getAttribute("data-payment"));if(0==Object.keys(e).length)throw new TypeError("no payment")}catch(t){return this.showMessage(this.const.LANG.FORM_VALIDATE_CHECKOUT_PAYMENT),!1}return!0},LadiPageScriptV2.prototype.runOptionFormCheckout=function(){for(var t=this,e=function(e){try{var i=t.findAncestor(e,"ladi-form-checkout-box"),a=JSON.parse(i.getAttribute("data-product"));if(isEmptyLadiPage(a.min))throw new TypeError("no min");return parseInt(a.min)||1}catch(t){return 1}},i=function(e){try{var i=t.findAncestor(e,"ladi-form-checkout-box"),a=JSON.parse(i.getAttribute("data-product"));if(isEmptyLadiPage(a.max))throw new TypeError("no max");return parseInt(a.max)||1}catch(t){return 1e6}},a=function(t){var a=parseInt(t.target.value);ai(t.target)&&(a=i(t.target)),t.target.value=a},n=function(t){var e=t.target.parentElement.querySelector("input");e.value=(parseInt(e.value)||0)+1,e.value>i(t.target)&&(e.value=i(t.target))},o=function(t){var i=t.target.parentElement.querySelector("input");i.value=(parseInt(i.value)||0)-1,i.value0&&0==g.querySelectorAll('[data-form-checkout-item="product"] .ladi-form-checkout-payment-check.checked').length&&g.querySelector('[data-form-checkout-item="product"] .ladi-form-checkout-payment-check').click()}catch(t){}}},LadiPageScriptV2.prototype.runOptionForm=function(t,e,i){var a,n=this,o=window.ladi("LADI_CAMP_TARGET_URL").get_cookie(),r=window.ladi("LADI_CAMP_CONFIG").get_cookie(),c=document.getElementsByClassName("ladi-form"),d=0,s=null,u=null,l=null,p=null,m=null,_=null,g=null,f=null,h=null,y=null,v=null,E=null,L=null,P=null,w=null,b=null,A=null,k=null,O=null,T=n.runtime.shopping,x=null,S=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],N=["name","email","phone","address","ward","district","state","country"],C=["email","phone"],D=n.copy(n.runtime.list_set_value_name_country).reverse(),R=function(t,e){var i="_capture_"+t,a=window.ladi(i).get_cookie(),o=!1,r=n.runtime.tmp["cookie_cache_otp_"+t];if(isEmptyLadiPage(a)&&isObjectLadiPage(r)&&!isEmptyLadiPage(r[i])&&(a=r[i],o=!0),isEmptyLadiPage(a)){a=e+"|"+n.runtime.ladipage_id+"|"+Date.now()+"|"+n.randomId();var c=new Date;c.setTime(c.getTime()+9e5),o?(r[i]=a,n.runtime.tmp["cookie_cache_otp_"+t]=r):window.ladi(i).set_cookie(a,c)}return a},F=function(t,e,i){var a=n.runtime.tmp["form_data_ladi_"+v];if(isObjectLadiPage(a))return!0;if(e&&isEmptyLadiPage(u[i]))return!1;var o=!0,r=t.getElementsByClassName("ladi-survey");for(f=0;f0)return e||n.showMessage(n.const.LANG.FORM_INPUT_REQUIRED_ERROR,null,function(){var e=t.querySelector('[name="'+_[0]+'"]');isEmptyLadiPage(e)||e.focus()}),!1;var g=!0,f=0,h=function(){var e=t.querySelector('[name="'+O[f].name+'"]');isEmptyLadiPage(e)||e.focus()};for(f=0;f()\\[\\]\\\\.,;:\\s@"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@"]+)*)|(".+"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))',pattern_flag:"gi",title:n.const.LANG.FORM_INPUT_EMAIL_REGEX}):isEmptyLadiPage(v)||O.push({name:o,pattern:v,title:isEmptyLadiPage(E)?n.const.LANG.FORM_INPUT_TEXT_REGEX:E}),"checkbox"==y){isArrayLadiPage(u[o])||(u[o]=[]),i[h].checked&&u[o].push(i[h].value);continue}if("radio"==y){i[h].checked&&(u[o]=i[h].value);continue}}if(u[o]=i[h].value,i[h].classList.contains("ladi-form-control-file")&&(u[o]=JSON.parse(i[h].getAttribute("data-path-file")||"[]"),m[o]=!0),"coupon"==o&&"INPUT"==i[h].tagName&&"text"==y&&"true"==i[h].getAttribute("data-replace-coupon")&&(u[o]=n.runtime.tmp.current_use_coupon||""),"INPUT"==i[h].tagName&&"date"==y&&!isEmptyLadiPage(u[o])){var L=i[h].getAttribute("date-format")||"dd-mm-yyyy",P=new Date(u[o]),w=L;w=(w=(w=(w=w.replaceAll("dd",(P.getDate()<10?"0":"")+P.getDate())).replaceAll("mm",(P.getMonth()+1<10?"0":"")+(P.getMonth()+1))).replaceAll("yyyy",P.getFullYear())).replaceAll("yy",P.getFullYear()-2e3),u[o]=w,l[o]=L}}return e||N.forEach(function(t){isNullLadiPage(u[t])||n.setCookieDomains("_ladipage_"+t,Base64.encode(u[t]),365)}),_=n.runtime.tmp.convertFormDataObjectCountry(u),{formDataObject:u}},q=function(t,e,a,c,p){var _=n.runtime.website_id,g={form_config_id:h,ladi_form_id:v,ladipage_id:n.runtime.ladipage_id,tracking_form:[],form_data:[],data_key:c};if(isEmptyLadiPage(_)||(g.website_id=_),a)g.status_send=n.const.STATUS_SEND.capture;else if(g.status_send=n.const.STATUS_SEND.sendform,T){var k=window.ladi("_checkout_token").get_cookie();isEmptyLadiPage(k)||(g.checkout_token=k)}if(isEmptyLadiPage(e.voucher_id)||(g.voucher_id=e.voucher_id),isEmptyLadiPage(e.voucher_code)||(g.voucher_code=e.voucher_code),!isEmptyLadiPage(E)){var O=E.getElementsByClassName("ladiflow-widget")[0];isEmptyLadiPage(O)||(isObjectLadiPage(g.options)||(g.options={}),g.options.ladiflow_trigger_id=O.getAttribute("ladiflow-trigger-id"),g.options.ladiflow_ref=O.getAttribute("ladiflow-ref"),g.options.ladiflow_page_id=O.getAttribute("page_id"),g.options.ladiflow_checkbox_user_ref=O.getAttribute("user_ref"),g.options.ladiflow_store_id=O.getAttribute("ladiflow-store-id"),d=1e3,s=function(){isObjectLadiPage(window.LadiFlow)&&isFunctionLadiPage(window.LadiFlow.resetWidgetCheckbox)&&window.LadiFlow.resetWidgetCheckbox(O.id)})}isEmptyLadiPage(L)||["option.sync_ladisales_form_account_id","option.sync_ladiflow_form_account_id","option.sync_ladishare_form_account_id","option.sync_ladichat_form_account_id"].forEach(function(t){isEmptyLadiPage(L[t])||(isObjectLadiPage(g.options)||(g.options={}),isArrayLadiPage(g.options.external_form_config_ids)||(g.options.external_form_config_ids=[]),g.options.external_form_config_ids.push(L[t]))}),e.isFormOtp&&!isEmptyLadiPage(y)&&(isObjectLadiPage(g.options)||(g.options={}),isObjectLadiPage(g.options.external_otp_config)||(g.options.external_otp_config={}),g.options.external_otp_config.otp_config_id=y),isObjectLadiPage(g.options)&&(g.options=JSON.stringify(g.options)),isEmptyLadiPage(P)||(g.total_revenue=P),isEmptyLadiPage(n.runtime.time_zone)||(g.time_zone=n.runtime.time_zone);var N=Object.keys(LadiFormApi);if((f=function(t){var e=[],i=0,a=["state","district","ward"];for(i=0;i0&&e.push("country"),isEmptyLadiPage(o)||e.except(["ward"]),i=e.length;i'+p[m].getAttribute("data-placeholder")+""),p[m].setAttribute("data-selected","");for(var _=document.querySelectorAll(".ladi-google-recaptcha-checkbox[data-widget-id]"),g=0;g<_.length;g++){var f=_[g].getAttribute("data-widget-id");isEmptyLadiPage(f)||window.grecaptcha&&isObjectLadiPage(n.runtime.tmp.google_captcha)&&n.runtime.tmp.google_captcha.checkbox&&isFunctionLadiPage(window.grecaptcha.reset)&&window.grecaptcha.reset(f)}var h=document.querySelectorAll(".ladi-form .ladi-form-checkbox-box-item");for(g=0;g0){var e=!1;-1!=[n.const.FORM_CONFIG_TYPE.haravan,n.const.FORM_CONFIG_TYPE.wordpress].indexOf(n.runtime.shopping_product_type)&&(e=!0);var i=n.runtime.tmp.cart[0];return i=JSON.stringify(i),i=encodeURIComponent(i),void n.removeAddToCartProduct(i,!1,e,function(e){e?_t(t):isFunctionLadiPage(t)&&t()})}-1!=[n.const.FORM_CONFIG_TYPE.ladisales].indexOf(n.runtime.shopping_product_type)&&(window.ladi("_cart_token").delete_cookie(),window.ladi("_checkout_token").delete_cookie(),n.createCartData()),isFunctionLadiPage(t)&&t()},gt=function(t,i,a,o){if(a.readyState==XMLHttpRequest.DONE){var r={};try{r=JSON.parse(t)}catch(t){}r=isObjectLadiPage(r)?r:{},o==n.const.API_FORM_DATA?200==r.code?rt++:(1!=r.code||isEmptyLadiPage(r.message)||(dt=r.message),ct++,pt=!1):200==i||201==i?rt++:n.getElementAHref(o).host==n.const.DOMAIN_GOOGLE_DOCS?rt++:ct++,rt+ct==st.length&&(pt&&!ut&&rt>=1?(ut=!0,c.isResendOtp||(n.runtime.tmp.form_data_current=u),isFunctionLadiPage(c.callbackOtp)&&c.callbackOtp(!0),isObjectLadiPage(c)&&isFunctionLadiPage(c.callbackThankyou)?(z(),c.callbackThankyou(c,function(){_t(function(){mt(!0),n.runtime.tmp.current_use_coupon=null})})):(H(),function(t,e,i){var a=null,o=!1,r=function(t,e){o||(isFunctionLadiPage(i)&&i(t,e),n.removeTimeout(a),o=!0)};a=n.runTimeout(r,3e3),n.runtime.tmp.runTrackingAnalytics("FormSubmit",{ladi_form_id:t,total_revenue:e},r)}(e.id,P,function(t,i){n.runEventTracking(e.id,{is_form:!0,event:{target:V}},u),window.ladi("_capture_"+e.id).delete_cookie(),isObjectLadiPage(c)&&isFunctionLadiPage(c.callbackOtpDone)&&c.callbackOtpDone(),_t(function(){n.runTimeout(function(){n.runtime.tmp.current_use_coupon=null,at(),mt(!0)},500)})}))):!lt&&ct>=1&&(isFunctionLadiPage(c.callbackOtp)&&c.callbackOtp(!1),lt=!0,n.showMessage(dt||n.const.LANG.REQUEST_SEND_ERROR),mt(!1)))}},ft=function(t){st.push({url:n.const.API_FORM_DATA,data:JSON.stringify(t),async:!0,headers:{"Content-Type":"application/json"},callback:gt})};K&&q(0,c,a,o,ft),isArrayLadiPage(Q)&&Q.forEach(function(t){if(!isEmptyLadiPage(t.api_url)&&isArrayLadiPage(t.custom_fields)){var e=n.getElementAHref(t.api_url).host==n.const.DOMAIN_GOOGLE_DOCS,i={},a=null,o=null,r=null,c=null;t.custom_fields.forEach(function(t){if(T&&("cart_products"==t.ladi_name&&(a=t.name),"cart_revenue"==t.ladi_name&&(o=t.name),"cart_shipping"==t.ladi_name&&(r=t.name),"cart_coupon_amount"==t.ladi_name&&(c=t.name)),!m[t.ladi_name]){var e=_[t.ladi_name];isNullLadiPage(e)||(isArrayLadiPage(e)?0==e.length?i[t.name]="":i[t.name]=JSON.stringify(e):i[t.name]=e)}}),isEmptyLadiPage(a)||isNullLadiPage(w)||(i[a]=JSON.stringify(w)),isEmptyLadiPage(o)||isNullLadiPage(P)||(i[o]=P),isEmptyLadiPage(r)||isNullLadiPage(n.runtime.tmp.add_to_cart_shipping_method_id)||(i[r]=n.runtime.tmp.add_to_cart_shipping_method_id+"|"+(n.runtime.tmp.add_to_cart_fee_shipping||0)),isEmptyLadiPage(c)||isEmptyLadiPage(n.runtime.tmp.current_use_coupon)||(i[c]=n.runtime.tmp.add_to_cart_discount||0);var d={};if(!isEmptyLadiPage(t.api_request_header))try{var s=JSON.parse(t.api_request_header);Object.keys(s).forEach(function(t){d[t]=s[t]})}catch(t){}if(!e)i.link=window.location.href,n.runtime.has_popupx&&(i.origin_link=n.runtime.tmp.popupx_origin_url),Object.keys(LadiFormApi).forEach(function(t){i[t]=LadiFormApi[t]}),S.forEach(function(t){var e=x[t];isNullLadiPage(e)||(i[t]=e)});var u=null,l=t.content_type||n.const.CONTENT_TYPE.form_urlencoded;if(l==n.const.CONTENT_TYPE.form_urlencoded&&(d["Content-Type"]="application/x-www-form-urlencoded",u=Object.keys(i).reduce(function(t,e){return t.push(e+"="+encodeURIComponent(i[e])),t},[]).join("&")),l==n.const.CONTENT_TYPE.json&&(d["Content-Type"]="application/json",u=JSON.stringify(i)),l==n.const.CONTENT_TYPE.form_data)u=new FormData,Object.keys(i).forEach(function(t){u.append(t,i[t])});st.push({url:t.api_url,data:u,async:!0,headers:d,callback:gt})}});(st.length>0||!K)&&W(),n.runTimeout(function(){0==st.length&&(K?j(0,c,N,o):q(0,c,a,o,ft)),st.forEach(function(t){n.sendRequest("POST",t.url,t.data,t.async,t.headers,t.callback)})},d)}}}}}},J=function(t){var e=n.findAncestor(t.target,"ladi-element");if(!isEmptyLadiPage(e))for(var i=e.querySelectorAll('[type="checkbox"]'),a=0;a0){y[0].setAttribute("required","required");for(var v=0;v0}))n.showMessage(n.const.LANG.ADD_TO_CART_PRODUCT_ONLY_ONE,{name:n.getMessageNameProduct(o.product.variants[s])});else{var v=n.runtime.tmp.cart.findIndex(function(t){return t.product_variant_id==u}),E=!1;if(-1==v){E=!0;var L={store_id:o.store_info.id,product_id:p,product_variant_id:u,name:m,title:_,price:g,image:y,quantity:0,min_buy:o.product.variants[s].min_buy,max_buy:o.product.variants[s].max_buy,inventory_checked:o.product.variants[s].inventory_checked,available_quantity:f,currency:o.store_info.currency,product_type:o.product.variants[s].product_type,package_quantity:o.product.variants[s].package_quantity};isObjectLadiPage(L.currency)&&!isEmptyLadiPage(L.currency.code)&&(L.currency.symbol=n.formatCurrency(null,L.currency.code,!1,!0)),n.runtime.tmp.cart.push(L),v=n.runtime.tmp.cart.length-1}var P=c.querySelector('input[name="quantity"]');if(isEmptyLadiPage(P)||isEmptyLadiPage(P.value))n.showMessage(n.const.LANG.ADD_TO_CART_QUANTITY_REQUIRED);else{var w=parseInt(P.value)||0;if(w<=0)return void n.showMessage(n.const.LANG.ADD_TO_CART_QUANTITY_REQUIRED);var b=null,A=1;A=o.product.variants[s].min_buy||A;var k=o.product.variants[s].max_buy;A>n.runtime.tmp.cart[v].quantity+w&&(w=A-n.runtime.tmp.cart[v].quantity);var O=!1;if(!isEmptyLadiPage(k)&&n.runtime.tmp.cart[v].quantity+w>k&&(w=k-n.runtime.tmp.cart[v].quantity)<=0&&(O=!0,b=k),1==o.product.variants[s].inventory_checked){if(A>f)return void n.showMessage(n.const.LANG.ADD_TO_CART_NO_QUANTITY,{name:n.getMessageNameProduct(o.product.variants[s],!0)});n.runtime.tmp.cart[v].quantity+w>f&&(w=f-n.runtime.tmp.cart[v].quantity,f>0&&(O=!0,(isEmptyLadiPage(b)||b>f)&&(b=f)))}if(O||w<=0&&f>0)n.showMessage(n.const.LANG.ADD_TO_CART_MAX_QUANTITY,{max:b,name:n.getMessageNameProduct(o.product.variants[s])},function(){var e=t.target;e=n.findAncestor(e,"ladi-button"),isEmptyLadiPage(e)||(e=n.findAncestor(e,"ladi-element"));var i=n.runtime.eventData[e.id];if(!isEmptyLadiPage(i)){var a=i["option.data_event"];if(!isArrayLadiPage(a)&&(a=[],isObjectLadiPage(i["option.data_action"]))){var o=n.copy(i["option.data_action"]);o.action_type=n.const.ACTION_TYPE.action,a.push(o)}a.forEach(function(t){t.action_type==n.const.ACTION_TYPE.action&&(t.type==n.const.DATA_ACTION_TYPE.popup_cart&&window.ladi("POPUP_CART").show(),t.type==n.const.DATA_ACTION_TYPE.popup_checkout&&(n.runtime.shopping_third_party?n.getThirdPartyCheckoutUrl(!0,null,{event:{target:r}}):window.ladi("POPUP_CHECKOUT").show(!1,{event:{target:r}})))})}});else if(w>0){var T=!isEmptyLadiPage(o.product.variants[s].start_date)&&new Date(o.product.variants[s].start_date).getTime()>Date.now(),x=!isEmptyLadiPage(o.product.variants[s].end_date)&&new Date(o.product.variants[s].end_date).getTime()0&&(e[o].value=r,Z&&n.fireEvent(e[o],"change"));else{if("country"==t&&"true"==e[o].getAttribute("data-is-select-country"))continue;"INPUT"==e[o].tagName&&"true"==e[o].getAttribute("data-is-select-country")&&2==(i=r.split(":")).length&&(r=i[1]),e[o].value=r,Z&&n.fireEvent(e[o],"change")}}},et=function(t){t.target.type="date",t.target.focus()},it=function(t){isEmptyLadiPage(t.target.value)&&(t.target.type="text")};for($=0;$mt&&(mt=_t),pt[lt].setAttribute("tabindex",n.runtime.tabindexForm+_t);for(pt=c[$].querySelectorAll("[data-tabindex]"),lt=0;ltmt&&(mt=_t),pt[lt].setAttribute("data-tabindex",n.runtime.tabindexForm+_t);n.runtime.tabindexForm+=mt;for(var gt=0;gta?1:-1},d=function(i){var a=window.LadiLocation[e];if(isObjectLadiPage(a)){var n=a.data[i];isEmptyLadiPage(n)||(t+='")}},s=function(t){var e=window.LadiLocation[t.target.getAttribute("data-country")];if(isObjectLadiPage(e)){var a=e.data[t.target.value.split(":")[0]];if(i="",!isEmptyLadiPage(a)&&isObjectLadiPage(a.data)){var c=Object.keys(a.data);o=a.data,c.sort(r),c.forEach(function(t){var e=a.data[t];i+='"})}var d=n.findAncestor(t.target,"ladi-element");if(!isEmptyLadiPage(d)){var s=d.querySelector('[name="district"]');isEmptyLadiPage(s)||"SELECT"==s.tagName&&(s.setAttribute("data-selected",""),s.innerHTML=s.querySelector("option").outerHTML+i);var u=d.querySelector('[name="ward"]');isEmptyLadiPage(u)||"SELECT"==u.tagName&&(u.setAttribute("data-selected",""),u.innerHTML=u.querySelector("option").outerHTML),LadiPageShopping.push(function(){n.reloadFeeShipping({target:u})})}}},u=function(t){var e=n.findAncestor(t.target,"ladi-element");if(!isEmptyLadiPage(e)){var i=e.querySelector('[name="ward"]');if(!isEmptyLadiPage(i)){a="";var c=e.querySelector('select[name="state"]');if(!isEmptyLadiPage(c)){var d=c.getAttribute("data-selected");if(!isEmptyLadiPage(d)){d=d.split(":")[0];var s=window.LadiLocation[c.getAttribute("data-country")];if(isObjectLadiPage(s)){var u=s.data[d];if(!isEmptyLadiPage(u)&&isObjectLadiPage(u.data)){var l=u.data[t.target.value.split(":")[0]];if(!isEmptyLadiPage(l)){var p=Object.keys(l.data);o=l.data,p.sort(r),p.forEach(function(t){var e=l.data[t];a+='"})}}}}}"SELECT"==i.tagName&&(i.setAttribute("data-selected",""),i.innerHTML=i.querySelector("option").outerHTML+a);var m=e.querySelector('[name="district"]');isEmptyLadiPage(m)||"SELECT"!=m.tagName||LadiPageShopping.push(function(){n.reloadFeeShipping({target:i})})}}},l=function(t){var e=n.findAncestor(t.target,"ladi-element");if(!isEmptyLadiPage(e)){var i=e.querySelector('[name="ward"]');isEmptyLadiPage(i)||"SELECT"!=i.tagName||LadiPageShopping.push(function(){n.reloadFeeShipping()})}};for($=0;$ .ladi-element [name="'+t+'"]');isEmptyLadiPage(e)||(e=n.findAncestor(e,"ladi-element"),window.ladi(e.id).value(i[t]))})}Object.keys(i).forEach(function(t){n.setDataReplaceStr(t,i[t])});var s=null,u=n.findAncestor(r,["ladi-popup","ladi-element"]);isEmptyLadiPage(u)||(s=u.id),n.setDataReplaceElement(!1,!1,null,s)}},LadiPageScriptV2.prototype.setEventDataFormDynamic=function(t){var e=this,i=function(){var t=e.runtime.tmp.form_data_dynamic;if(isNullLadiPage(t))try{var i=document.getElementById("script_form_data_dynamic");isEmptyLadiPage(i)||(t=JSON.parse(i.innerHTML),t=e.deOptimizeEventData(t,LadiPageScript.const.OPTIMIZE_EVENT_DATA_KEY_LIST,"OPTIMIZE_EVENT_DATA_KEY_LIST"),e.runtime.tmp.form_data_dynamic=t)}catch(t){}return t}();if(isArrayLadiPage(i)&&i.length>0){var a="event_data_"+t;isNullLadiPage(e.runtime.tmp[a])&&isObjectLadiPage(e.runtime.eventData[t])&&(e.runtime.tmp[a]=e.copy(e.runtime.eventData[t]));var n=isObjectLadiPage(e.runtime.tmp[a])?e.copy(e.runtime.tmp[a]):e.runtime.eventData[t],o=!0,r=function(t,e,i){var a=!1;"NOT_CONTAINS"!=e&&"NOT_STARTS_WITH"!=e&&"NOT_ENDS_WITH"!=e&&"!="!=e&&"NOT_IN"!=e||(a=!0);var n=isEmptyLadiPage(i)?"":i;n=(n=isStringLadiPage(n)?n:String(n)).toLowerCase();for(var o=0==i?0:parseFloatLadiPage(i)||null,r=0;r"==e&&o>d){a=!0;break}if(">="==e&&o>=d){a=!0;break}if("<"==e&&o .ladi-form > .ladi-element[id="'+i.form_item_value+'"]')),"name"==i.form_item_type&&(a=document.querySelector("#"+t+' > .ladi-form > .ladi-element [name="'+i.form_item_value+'"]'),a=e.findAncestor(a,"ladi-element")),o=!isEmptyLadiPage(a)&&r(i.value,i.operator,window.ladi(a.id).value())),"FORM"==i.type&&(o=r(i.value,i.operator,t))}catch(t){o=!1}};i.forEach(function(t){isObjectLadiPage(t.form_data)&&(o=!0,isArrayLadiPage(t.conditions)&&t.conditions.forEach(c),o&&(n=e.copy(t.form_data)))}),e.runtime.eventData[t]=n}},LadiPageScriptV2.prototype.setInputOtp=function(){for(var t=this,e=document.querySelectorAll(".ladi-form .ladi-element .ladi-form-otp"),i=function(e,a){var n=t.findAncestor(a,"ladi-form");if(!isEmptyLadiPage(n)&&(n=t.findAncestor(n,"ladi-element"),!isEmptyLadiPage(n))){var o="_otp_time_"+n.id,r=window.ladi(o).get_cookie(),c=t.runtime.tmp["cookie_cache_otp_"+n.id];isEmptyLadiPage(r)&&isObjectLadiPage(c)&&!isEmptyLadiPage(c[o])&&(r=c[o]);var d=(r=parseFloatLadiPage(r)||0)+t.runtime.time_otp-Date.now();d=dt.const.FORM_UPLOAD_FILE_LENGTH)t.showMessage(t.const.LANG.FORM_UPLOAD_FILE_MAX_LENGTH_ERROR,{max_length:t.const.FORM_UPLOAD_FILE_LENGTH});else{for(var n=new FormData,o=0,r=0;r1024*t.const.FORM_UPLOAD_FILE_SIZE*1024)t.showMessage(t.const.LANG.FORM_UPLOAD_FILE_MAX_SIZE_ERROR,{max_size:t.const.FORM_UPLOAD_FILE_SIZE});else{var c={ladipage_id:t.runtime.ladipage_id,lang:t.runtime.lang};n.append("json_data",JSON.stringify(c)),t.showLoadingBlur(),t.sendRequest("POST",t.const.API_FILE_UPLOAD,n,!0,null,function(i,a,n){if(n.readyState==XMLHttpRequest.DONE){if(t.hideLoadingBlur(),200==a)try{var o=JSON.parse(i);if(200==o.code){var r=[],c=[];return o.data.success.forEach(function(t){r.push(t.name),c.push({id:t._id,path:t.path,name:t.name})}),e.value=r.length>0?"["+r.join(", ")+"]":"",void e.setAttribute("data-path-file",JSON.stringify(c))}if(!isEmptyLadiPage(o.message))return void t.showMessage(o.message)}catch(t){}t.showMessage(t.const.LANG.REQUEST_SEND_ERROR)}}),isFunctionLadiPage(a)&&a()}}}(i=document.querySelector('[data-click-id="'+e.target.getAttribute("data-file-click-id")+'"]'),e.target.files,function(){e.target.value=null})})),n.click()},a=0;a